<jsp:useBean id="db" scope="session" class="com.jipl.Masters.DatabaseBean"/>              
<jsp:setProperty name="db" property="*"/>
<%@ page import="java.io.* ,java.util.*, java.sql.*,com.jipl.login.*"%>


<html xmlns="http://www.w3.org/1999/xhtml">
    <!-- DW6 -->
    <head>

        <title>Edit Purchase</title>

        <script language="JavaScript" type="text/javascript">
            function displayHTML(printContent)
            {
                var int=printContent;
                win=window.open("print.htm",'popup','toolbar=no, status=no');
                win.document.write(int);
                window.print();
            }
            function validate()
            {
                var index1=document.form2.select1.selectedIndex;
                if(index1==0)
                {
                    alert("Please Make a Selection from Supplier Name");
                    document.form2.select1.focus();
                    return false;
                }
            }
        </script>
        <style type="text/css">
            <!--
            .style10 {color: #FFFFFF}
            a:link {
                color: #990000;
                text-decoration: none;
            }
            -->
        </style>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
        <link href="../../images/mm_health_nutr.css" rel="stylesheet" type="text/css">
        <style type="text/css">
            <!--
            a:visited {
                text-decoration: none;
            }
            a:hover {
                text-decoration: none;
            }
            a:active {
                text-decoration: none;
            }
            .style15 {font-size: 14px}
            .style16 {font-weight: bold}
            -->
        </style>
    </head>
    <body bgcolor="#F4FFE4">
        <table width="102%" border="0" cellspacing="0" cellpadding="0">
            <tr bgcolor="#D5EDB3">
                <td width="259" rowspan="2" background="../../images/mm_health_photo copy.jpg">&nbsp;</td>
                <td width="540" height="50" align="center" valign="bottom" nowrap="nowrap" background="../../images/flash_header1.png" class="pageName" id="logo">Stores and Material Management</td>
                <td width="199" background="../../images/flash_header1.png">&nbsp;</td>
            </tr>
            <tr bgcolor="#D5EDB3">
                <td height="49" align="center" valign="top" background="../../images/flash_header2.png" id="tagline">&nbsp;</td>
                <td width="199" background="../../images/flash_header2.png">&nbsp;</td>
            </tr>
            <tr>
                <td colspan="3" bgcolor="#5C743D"></td>
            </tr>
            <tr>
                <td colspan="3" bgcolor="#99CC66" ></td>
            </tr>
            <tr bgcolor="#99CC66">
                <td height="28" background="../../images/flash_menubar.png"><a href="../Entries.jsp"><strong>HOME</strong></a>&nbsp;::&nbsp;<a href="PurchaseHome.jsp"><strong>BACK</strong></a>&nbsp;&nbsp;&nbsp;&nbsp;
                    <script language="JavaScript" type="text/javascript">
                        document.write(TODAY);	</script></td>
                <td height="28" align="center" background="../../images/flash_menubar.png"><span class="style16"><a href="../../masters/Masters.jsp">Masters</a> <a href="../Entries.jsp">Entries</a> <a href="../../reports/AdminReporting.jsp">Reports</a></span></td>
                <td height="28" background="../../images/flash_menubar.png">&nbsp;</td>
            </tr>

            <tr>
                <td colspan="3" bgcolor="#5C743D"><img src="../../images/mm_spacer.gif" alt="" width="1" height="2" border="0" /></td>
            </tr>
            <th height="536" colspan="3" align="center" bgcolor="#536A3E">

                <%
               db.connect();
               request.getSession(true);
               String user=session.getAttribute("un").toString();
                String user_name_query="select distinct(location) from user_reg where uid='"+user+"';";
                      String loc="";
                      ResultSet rs21=db.execSQL(user_name_query);
                      if (rs21.next()==true)
                                      loc=rs21.getString(1);
                      else if(rs21.next()==false)
                                        {
                                                String qad1="SELECT location FROM admin where un='"+user+"' ";
                                                ResultSet rst1=db.execSQL(qad1);
                                                if(rst1.next()==true)
                                                {
                                                              loc=rst1.getString(1);
                                                }
                                        }
                                        session.setAttribute("loc",loc);
                String getpids="select distinct(pid) from purchase where location='"+loc+"' and ptype='P'";
                System.out.println(getpids);
                ResultSet pids=db.execSQL(getpids);
                %>
                <form name="form1" method="post" action="editPurchase2.jsp">
                    <table width="287" border="0">
                        <tr background="images/flash_body.png">
                            <th height="33" colspan="2" background="../../images/flash_header1.png" scope="row">Select Purchase ID </th>
                        </tr>
                        <tr>
                            <th width="117" background="../../images/flash_body.png"><span class="style15 style10"><strong>Purchase ID </strong></span></th>
                            <th width="154" background="../../images/flash_body.png"><span class="style15">
                                    <select name="pid" id="pid">
                                        <option> </option>
                                        <%
                                                             while (pids.next()==true)
                                                            {%>
                                        <option><%= pids.getString(1) %> </option>
                                        <%} %>
                                    </select>
                                </span></th>
                        </tr>
                        <tr>
                            <td colspan="2" align="center" background="../../images/flash_body.png"><label>
                                    <input type="submit" name="Submit2" value="Submit">
                                </label></td>
                        </tr>
                    </table>
                </form>  </tr>
            <tr>
                <td colspan="3" bgcolor="#536A3E">&nbsp;</td>
            </tr>
        </table>
    </body>
</html>
